package for_all;

// -----------------------------------------------------------------------------
// Importanweisungen
import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;


public class Message implements Serializable {
    
    // -------------------------------------------------------------------------
    // Variablendaklarationen
    private String message;     // eigentliche Message
    private String sender;      // Absender der Message
    private String timestamp;   // Timestamp der Message, Zeitpunkt des Absendens
    private String raum;        // Raum der Message
    private boolean privateChat;
    
    
    // -------------------------------------------------------------------------
    // Konstruktor
    public Message (String message, String sender, String roomName, boolean privateChat) {
        
        this.message = message;
        this.sender = sender;
        this.timestamp = new SimpleDateFormat("dd.MM.-HH:mm").format(new Date());
        this.raum = roomName;
        this.privateChat = privateChat;
    
    }
    
    
    // -------------------------------------------------------------------------
    // Names des Raumes für die Nachricht
    public String getRoomName() {
        return this.raum;
    }
    
    
    // -------------------------------------------------------------------------
    // gibt die Message aus (Chatprotokoll)
    public String getMessage () {
        return "<<" + this.getTimestamp() + ">> " + this.sender + ": " + this.message;
    }
    
    
    // -------------------------------------------------------------------------
    // Absender zurückgeben
    public String getSender() {
        return this.sender;
    }
    
    
    // -------------------------------------------------------------------------
    // gibt den Timestamp im geünschten Format als String zurück
    private String getTimestamp() {
        return this.timestamp.toString();
    }
    
    
    // -------------------------------------------------------------------------
    //
    public boolean getPrivate() {
        return this.privateChat;
    }
    
    // -------------------------------------------------------------------------
    //
    public String getPureText() {
        return this.message;
    }
}